<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="javax.persistence.Query"%>
<%@page import="javax.persistence.EntityManager"%>
<%@ page import="biblioteca.dao.EMF" %>
<%@ page import="biblioteca.persistencia.Libro" %>
<%@ page import="java.util.List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Libros</title>
</head>
<body background="/stylesheets/muestraL.png">
<% String listar = request.getParameter("listar");
if(listar.compareTo("books")== 0){
	EntityManager pm = EMF.get().createEntityManager();
    String query = "SELECT FROM biblioteca.Libro";
    Query consulta = pm.createQuery(query);
    List<Libro> greetings = (List<Libro>) consulta.getResultList();
    if (greetings.isEmpty()) { %>
<form action="index.html">
	<h1>No hay Libros disponibles actualmente</h1>
</form>
<%}else{
	for (Libro g : greetings) {	%>
	<fieldset>
		<h3 style="color:white">Datos del libro: <%= g.getTitulo()%></h3>
		<code style="color:white">ISBN:</code><code style="color:white"><%= g.getIsbn() %></code><br> 
		<code style="color:white">EDITORIAL:</code><code style="color:white"><%= g.getEditorial() %></code><br> 
		<code style="color:white">AUTOR:</code><code style="color:white"><%= g.getAutor() %></code><br> 
		<code style="color:white">TIENECD:</code><code style="color:white"><%= g.getTieneCD() %></code><br> 
		<code style="color:white">DESCRIPCIÓN</code><code style="color:white"><%= g.getContent() %></code><br>
		
	</fieldset>	
	
		<%}
 		}
    } %>
<form action="index.html">
	<input type="image" src="/stylesheets/atras.png"  >
</form>
</body>
</html>